<?php
class ReaderTypeModel extends Model{
	//获取全部读者类型
	public function getAllReaderType(){
		$sql="select * from {$this->table}";
		return $this->db->getAll($sql);
	}
	
	//分页获取读者类型
	public function getAllTypes($offset,$pagesize){
		$sql="SELECT tb_readertype.*,b.num FROM tb_readertype 
				LEFT JOIN (SELECT COUNT(*) as num,typeid  from tb_reader GROUP BY typeid) AS b 
				ON tb_readertype.id=b.typeid order by id desc limit {$offset},{$pagesize}";
		return $this->db->getAll($sql);
	}
	
	public function addAction(){
		
	}
}